<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/2/7
 * Time: 22:20
 */

namespace Xcx\Model;

class GoodsCouponModel extends BaseModel {

    /**
     * 获取可以被兑换的商品优惠券列表
     * @return false|mixed
     */
    public function getGoodsCouponList()
    {
        $maps['remain'] = array('GT',0);
        $maps['state'] = array('EQ',1);
        return $this->where($maps)->select();
    }

    /**
     * 获取商品优惠券详细信息
     * @param $id 优惠券ID
     * @return array|false|mixed|\PDOStatement|string|\think\Model
     */
    public function getGoodsCouponInfo($id)
    {
        return $this->where(array('id'=>$id))->find();
    }

    /**
     * 减少商品优惠券数量
     * @param $id
     * @return bool|int|true
     */
    public function setDecGoodsCouponRemain($id)
    {
        return $this->where(array('id'=>$id))->setDec('remain');
    }

}